package models

import "gorm.io/gorm"

type Patient struct {
	gorm.Model
	Name       string `gorm:"type:varchar(20);not null"`
	IdCard     string `gorm:"type:varchar(20);not null"`
	NickName   string `gorm:"type:varchar(20);not null"`
	Address    string `gorm:"type:varchar(30);not null"`
	CardNumber string `gorm:"type:varchar(20);not null"`
	IdNumber   string `gorm:"type:varchar(20);not null"`
	Tel        string `gorm:"type:char(11);not null"`
}

func (p *Patient) PatientAdd(db *gorm.DB) error {
	return db.Debug().Create(p).Error
}

func (p *Patient) PatientShowById(db *gorm.DB, id int64) error {
	return db.Debug().Where("id = ?", id).First(p).Error
}

func (p *Patient) PatientDel(db *gorm.DB, id int64) error {
	return db.Debug().Where("id = ?", id).Delete(p).Error
}
